<?php // content="text/plain; charset=utf-8"
require_once ("jpgraph/jpgraph.php");
require_once ("jpgraph/jpgraph_bar.php");
require_once ("jpgraph/jpgraph_line.php");

 $size = count($keysCol)*50;
// Create the graph. 
$graph = new Graph($size,300);	
$graph->SetScale("textlin");
$graph->SetMarginColor('white');

// Adjust the margin slightly so that we use the 
// entire area (since we don't use a frame)
$graph->SetMargin(30,1,35,0);

// Box around plotarea
$graph->SetBox(); 

// No frame around the image
$graph->SetFrame(false);

// Setup the tab title
//$graph->tabtitle->Set('Year 2003');
//$graph->tabtitle->SetFont(FF_ARIAL,FS_BOLD,10);

// Setup the X and Y grid
$graph->ygrid->SetFill(true,'#DDDDDD@0.5','#BBBBBB@0.5');
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->SetColor('gray');
//$graph->xgrid->Show();
//$graph->xgrid->SetLineStyle('dashed');
//$graph->xgrid->SetColor('gray');

// Setup month as labels on the X-axis
$graph->xaxis->SetTickLabels($keysCol);
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,8);
$graph->xaxis->SetLabelAngle(0);

// Create a bar pot
$bplot1 = new BarPlot($ydata1);
$bplot2 = new BarPlot($ydata2);
//$bplot3 = new BarPlot($ydata3);
//$bplot4 = new BarPlot($ydata4);

$bplot1->value->HideZero();
$bplot2->value->HideZero();
//$bplot3->value->HideZero();
//$bplot4->value->HideZero();

$bplot1->value->setFormat("%d");
$bplot2->value->setFormat("%d");
//$bplot3->value->setFormat("%d");
//$bplot4->value->setFormat("%d");

$bplot1->value->show();
$bplot2->value->show();
//$bplot3->value->show();
//$bplot4->value->show();

$fcol='#440000';
$tcol1='#FF9090';
$tcol2='#0000FF';
$tcol3='#00FF00';
$tcol4='#F90909';

$bplot1->SetFillGradient($fcol,$tcol1,GRAD_LEFT_REFLECTION);
$bplot2->SetFillGradient($fcol,$tcol2,GRAD_LEFT_REFLECTION);
//$bplot3->SetFillGradient($fcol,$tcol3,GRAD_LEFT_REFLECTION);
//$bplot4->SetFillGradient($fcol,$tcol4,GRAD_LEFT_REFLECTION);

// Set line weigth to 0 so that there are no border
// around each bar
$bplot1->SetWeight(0);
$bplot2->SetWeight(0);
//$bplot3->SetWeight(0);
//$bplot4->SetWeight(0);

// Setup legends
$bplot1->SetLegend('Local');
$bplot2->SetLegend('Overseas');
//$bplot3->SetLegend('Factory');
//$bplot4->SetLegend('Project');

//$gbarplot = new GroupBarPlot(array($bplot1,$bplot2, $bplot3, $bplot4));
$gbarplot = new GroupBarPlot(array($bplot1,$bplot2));

$graph->legend->Pos(0,0);
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->SetFont(FF_ARIAL,FS_NORMAL,8);

$bplot1->value->SetColor($tcol1); 
$bplot2->value->SetColor($tcol2); 
//$bplot3->value->SetColor($tcol3); 
//$bplot4->value->SetColor($tcol4); 

$graph->Add($gbarplot);

@unlink('report/example1.png');
$graph->Stroke('report/example1.png');

echo image_tag('/report/example1.png', array('alt' => __('Completed'), 'title' => __('Completed')));
?>
